const lodash = require('lodash');
const path = require('path');

module.exports = {
    _: lodash,
    resource: path.join(think.ROOT_PATH, 'www'),
    cmswing: {
        center: require(path.join(think.ROOT_PATH, 'src', 'controller', 'cmswing', 'center')),
        modIndex: require(path.join(think.ROOT_PATH, 'src', 'controller', 'cmswing', 'modindexbase')),
        extIndex: require(path.join(think.ROOT_PATH, 'src', 'controller', 'cmswing', 'extindexbase')),
    },
    extModel(modelName = '', extName = '', config = think.config('model.mysql'), prefix = 'ext_') {
        try {
            const Cls = think.app.controllers[`ext/${extName}/model/${modelName}`];
            return new Cls(`${prefix}${modelName}`, config);
        } catch (e) {
            return think.model(`${prefix}${modelName}`);
        }
    },
}